function deletar(url){
    if(confirm("Deseja realmente deletar esse registro?")){
        window.location=url;
    }
}
function delAjax(url,idDiv, urlRedirect){
    if(confirm("Deseja realmente deletar esse registro?")){
        $.get(url);
        $('#'+idDiv).load(urlRedirect);
    }
}

function popIn(idJ,url){
        $( "#"+idJ ).dialog( 'open','width', 500 );
        if (url == ''){

        }else{
        $("#"+idJ).load(url);
        }
        
    }

		function criaJanela(id,icone,titulo,pagina,tamH,tamW,modal,botoes,idConversa){
			var parametros = {
				icon: icone,
				icon_draggable: true,
				dock: "#quick-bar",
				dock_sortable: true,
				collapsed: false
			}

			var div = document.getElementById(id);
			if (div) {
				return false;
			}

			$("body").append('<div id='+id+' title='+titulo+'><div id=dvCont'+id+'></div></div>');

			result = $('#'+id).dialog({
							   closeOnEscape: true,
							   height: tamH,
							   width:tamW,
							   modal:modal,
							   title:titulo,
							   maxHeight:screen.availHeight - 170,
							   maxWidth:screen.width -50,
							   stack: true,
							   focus: function() {
								   },
							   beforeClose: function() {
								   	$(this).remove();                                                                        
									
								},
							   buttons: botoes
							});

			$('#dvCont'+id).load(pagina);
				if (modal != true){				
			}

			return result;
		}



function geraID(){
var l = "abcdefghijklmnopqrstuvwxyz";
var n = "0123456789";

    for(i=1;i<=4;i++) {
        rn = parseInt(Math.random()*10);
        rl = parseInt(Math.random()*26);

        if(i > 1) {
            pw=pw+l.charAt(rl)+n.charAt(rn);
        } else {
            pw=l.charAt(rl)+n.charAt(rn);
        }
    }
    return "ID"+pw;
}

function AbreJanela(url, width, height, title, idConversa){
	var idJanela = this.geraID();
	//var div = this.geraID();

	//$("body").append("<div id="+idJanela+"><div id="+idConteudo+"></div></div>");

	var Janela = criaJanela(idJanela,title,title,url,height,width,false,'',idConversa);
	Janela.dialog('open');

}